package com.example.springsecurityoauth2demo.service.impl;

import com.example.springsecurityoauth2demo.model.dao.UserMapper;
import com.example.springsecurityoauth2demo.model.pojo.User;
import com.example.springsecurityoauth2demo.model.req.ReqUser;
import com.example.springsecurityoauth2demo.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Liusr
 * @date 2024/3/1
 * @package com.example.springsecurityoauth2demo.service.impl
 * @Description:
 */
@Service
public class UserServiceImpl implements UserService {

	@Resource
	private UserMapper userMapper;

	@Override
	public List<User> getAllUsers() {
		return userMapper.selectAllUsers();
	}

	@Override
	public User getUserByUserName(String username) {
		return userMapper.selectUserByUsername(username);
	}

	@Override
	public Object save(ReqUser reqUser) {
		User user = new User();
		BeanUtils.copyProperties(reqUser, user);
		return userMapper.insert(user);
	}
}
